﻿using System;
using System.Runtime.InteropServices;
//using System.Security.Permissions;

namespace ContentManager
{
    public enum CRfcConnectionStatus : int
    {
        tloRfcNotConnected = 0,
        tloRfcConnected = 1,
        tloRfcConnectCancel = 2,
        tloRfcConnectParameterMissing = 4,
        tloRfcConnectFailed = 8
    }
    
    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("E2D74A49-184A-11CF-8984-0000E8A49FA0")]
    public interface ISAPLogonConnection
    {
        [DispId(0x10)] //, PermissionSet(SecurityAction.Assert)]
        void set_RfcWithDialog([MarshalAs(UnmanagedType.I4)] Int64 i);

        [DispId(0x10)]
        [return: MarshalAs(UnmanagedType.I4)]
        Int64 get_RfcWithDialog();

        [DispId(0x16)]
        bool Logon([MarshalAs(UnmanagedType.AsAny)] object hWnd, [MarshalAs(UnmanagedType.VariantBool)] bool bSilent);

        [DispId(0x15)]
        void Logoff();

        [DispId(0x14)]
        [return: MarshalAs(UnmanagedType.VariantBool)]
        bool Reconnect();

        string CodePage
        {
            [DispId(0x24)]
            [return: MarshalAs(UnmanagedType.BStr)]
            get;
        }

        CRfcConnectionStatus IsConnected
        {
            [DispId(0x0e)]
            [return: MarshalAs(UnmanagedType.U4)]
            get;
        }

        string SystemID
        {
            [DispId(0x1b)]
            [return: MarshalAs(UnmanagedType.BStr)]
            get;
        }

    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("B24944D7-1501-11CF-8981-0000E8A49FA0")]
    public interface ISAPLogonControl
    {
        [DispId(0x0e)]
        [return: MarshalAs(UnmanagedType.IDispatch)]
        object NewConnection();
    }
}
